<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>NeuZephyr: D:/Users/Mgepahmge/Documents/C Program/NeuZephyr/include/NeuZephyr/ComputeGraph.cuh File Reference</title>
<link rel="icon" href="NZ_logo2.png" type="image/x-icon" />
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="NZ_logo2.png"/></td>
  <td id="projectalign">
   <div id="projectname">NeuZephyr
   </div>
   <div id="projectbrief">Simple DL Framework</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.12.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d522931ffa1371640980b621734a4381.html">Users</a></li><li class="navelem"><a class="el" href="dir_a7e6ee1ae3f772c9504a0b543f2027e2.html">Mgepahmge</a></li><li class="navelem"><a class="el" href="dir_e03f57e346cc4845a4c354a35630b169.html">Documents</a></li><li class="navelem"><a class="el" href="dir_231a0482af2b83c895f27ba7fe745141.html">C Program</a></li><li class="navelem"><a class="el" href="dir_0fa7fc3a0dfd304dbfc9dce9f6facfa2.html">NeuZephyr</a></li><li class="navelem"><a class="el" href="dir_e7295b03dab2e9cdf32139bd8ec2e607.html">include</a></li><li class="navelem"><a class="el" href="dir_657344ecc65cfc28732701509f8d8421.html">NeuZephyr</a></li>  </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#namespaces">Namespaces</a>  </div>
  <div class="headertitle"><div class="title">ComputeGraph.cuh File Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Defines the ComputeGraph class for constructing and managing computational graphs in neural network models.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;string&gt;</code><br />
<code>#include &lt;queue&gt;</code><br />
<code>#include &quot;<a class="el" href="_operation_kernels_8cuh_source.html">OperationKernels.cuh</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="_optimizer_8cuh_source.html">Optimizer.cuh</a>&quot;</code><br />
<code>#include &quot;utils.cuh&quot;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for ComputeGraph.cuh:</div>
<div class="dyncontent">
<div class="center"><img src="_compute_graph_8cuh__incl.png" border="0" usemap="#a_d_1_2_users_2_mgepahmge_2_documents_2_c_01_program_2_neu_zephyr_2include_2_neu_zephyr_2_compute_graph_8cuh" alt=""/></div>
<map name="a_d_1_2_users_2_mgepahmge_2_documents_2_c_01_program_2_neu_zephyr_2include_2_neu_zephyr_2_compute_graph_8cuh" id="a_d_1_2_users_2_mgepahmge_2_documents_2_c_01_program_2_neu_zephyr_2include_2_neu_zephyr_2_compute_graph_8cuh">
<area shape="rect" title="Defines the ComputeGraph class for constructing and managing computational graphs in neural network m..." alt="" coords="75,5,277,80"/>
<area shape="rect" title=" " alt="" coords="5,128,59,155"/>
<area shape="poly" title=" " alt="" coords="123,83,65,121,62,117,120,78"/>
<area shape="rect" title=" " alt="" coords="82,128,139,155"/>
<area shape="poly" title=" " alt="" coords="154,82,130,116,126,113,149,79"/>
<area shape="rect" href="_operation_kernels_8cuh.html" title="CUDA Kernel Definitions for High&#45;Performance Tensor Operations." alt="" coords="71,277,217,304"/>
<area shape="poly" title=" " alt="" coords="174,81,150,263,145,262,169,80"/>
<area shape="rect" href="_optimizer_8cuh.html" title="Definition of optimization algorithms for training deep learning models." alt="" coords="213,128,315,155"/>
<area shape="poly" title=" " alt="" coords="211,78,244,114,240,118,207,82"/>
<area shape="rect" href="utils_8cuh_source.html" title=" " alt="" coords="461,203,531,229"/>
<area shape="poly" title=" " alt="" coords="246,78,460,193,458,197,243,83"/>
<area shape="rect" title=" " alt="" coords="78,427,135,453"/>
<area shape="poly" title=" " alt="" coords="128,306,107,327,90,353,87,368,88,383,96,412,91,414,82,384,82,367,86,351,103,323,125,303"/>
<area shape="rect" href="_dimension_8cuh_source.html" title=" " alt="" coords="144,352,253,379"/>
<area shape="poly" title=" " alt="" coords="156,303,182,338,178,341,151,306"/>
<area shape="poly" title=" " alt="" coords="184,381,136,419,133,415,181,377"/>
<area shape="rect" title=" " alt="" coords="440,427,512,453"/>
<area shape="poly" title=" " alt="" coords="248,377,426,423,424,428,246,382"/>
<area shape="rect" title=" " alt="" coords="190,427,268,453"/>
<area shape="poly" title=" " alt="" coords="206,378,221,411,216,413,202,380"/>
<area shape="rect" href="dl__export_8cuh_source.html" title=" " alt="" coords="309,427,408,453"/>
<area shape="poly" title=" " alt="" coords="228,377,318,417,316,422,225,382"/>
<area shape="rect" title=" " alt="" coords="326,203,436,229"/>
<area shape="poly" title=" " alt="" coords="286,153,350,192,347,197,283,157"/>
<area shape="rect" href="_nodes_8cuh.html" title="Declaration of the Node class and various derived node classes for neural network operations." alt="" coords="218,203,302,229"/>
<area shape="poly" title=" " alt="" coords="266,155,264,187,259,187,261,155"/>
<area shape="rect" title=" " alt="" coords="351,277,420,304"/>
<area shape="poly" title=" " alt="" coords="283,228,352,267,349,272,281,232"/>
<area shape="rect" href="_tensor_8cuh.html" title="Definition of the Tensor class for GPU&#45;based tensor operations." alt="" coords="241,277,327,304"/>
<area shape="poly" title=" " alt="" coords="267,229,278,262,273,263,262,231"/>
<area shape="poly" title=" " alt="" coords="242,307,178,329,151,342,134,354,118,382,111,412,106,411,113,380,130,350,149,337,176,324,240,302"/>
<area shape="poly" title=" " alt="" coords="271,307,226,344,223,340,267,303"/>
<area shape="poly" title=" " alt="" coords="285,305,280,339,268,380,249,415,244,412,263,378,274,338,280,304"/>
<area shape="poly" title=" " alt="" coords="328,299,369,318,388,332,404,351,409,368,405,386,385,417,381,414,400,384,403,368,399,353,385,336,367,323,326,304"/>
<area shape="rect" title=" " alt="" coords="328,352,389,379"/>
<area shape="poly" title=" " alt="" coords="299,303,337,339,333,343,295,306"/>
<area shape="poly" title=" " alt="" coords="498,230,481,412,476,411,492,230"/>
</map>
</div>
</div><div class="textblock"><div class="dynheader">
This graph shows which files directly or indirectly include this file:</div>
<div class="dyncontent">
<div class="center"><img src="_compute_graph_8cuh__dep__incl.png" border="0" usemap="#a_d_1_2_users_2_mgepahmge_2_documents_2_c_01_program_2_neu_zephyr_2include_2_neu_zephyr_2_compute_graph_8cuhdep" alt=""/></div>
<map name="a_d_1_2_users_2_mgepahmge_2_documents_2_c_01_program_2_neu_zephyr_2include_2_neu_zephyr_2_compute_graph_8cuhdep" id="a_d_1_2_users_2_mgepahmge_2_documents_2_c_01_program_2_neu_zephyr_2include_2_neu_zephyr_2_compute_graph_8cuhdep">
<area shape="rect" title="Defines the ComputeGraph class for constructing and managing computational graphs in neural network m..." alt="" coords="123,5,325,80"/>
<area shape="rect" href="_model_8cuh.html" title="Core class for computational graph construction and neural network modeling." alt="" coords="5,128,208,203"/>
<area shape="poly" title=" " alt="" coords="179,93,144,129,140,126,176,90"/>
<area shape="rect" href="_compute_graph_8cu_source.html" title=" " alt="" coords="232,136,453,195"/>
<area shape="poly" title=" " alt="" coords="273,89,316,134,312,137,269,93"/>
<area shape="rect" href="_model_8cu_source.html" title=" " alt="" coords="22,251,191,309"/>
<area shape="poly" title=" " alt="" coords="109,218,109,250,104,250,104,218"/>
</map>
</div>
</div>
<p><a href="_compute_graph_8cuh_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classnz_1_1graph_1_1_compute_graph.html">nz::graph::ComputeGraph</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Represents a computational graph, which manages nodes and the computation flow.  <a href="classnz_1_1graph_1_1_compute_graph.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a>
Namespaces</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">namespace &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacenz_1_1graph.html">nz::graph</a></td></tr>
<tr class="memdesc:namespacenz_1_1graph"><td class="mdescLeft">&#160;</td><td class="mdescRight">Contains classes and functions for managing and executing computation graphs in deep learning workflows. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Defines the ComputeGraph class for constructing and managing computational graphs in neural network models. </p>
<p>This header file defines the <code>ComputeGraph</code> class, which serves as the backbone for representing and manipulating computational graphs in deep learning frameworks. The class provides functionalities for adding nodes, managing their interconnections, and performing forward and backward passes through the network.</p>
<p>A computational graph consists of nodes (which represent operations or variables) and edges (which define dependencies between these operations). <code>ComputeGraph</code> abstracts the creation and manipulation of these nodes, offering a unified API for building and training deep learning models.</p>
<p>Key functionalities provided by the <code>ComputeGraph</code> class:</p><ul>
<li><b>Node Management</b>: The class allows for the addition of various types of nodes such as input, output, and computation nodes (e.g., Add, MatMul, ReLU). Nodes can be connected to form a network.</li>
<li><b>Forward/Backward Pass</b>: The class supports forward and backward propagation through the graph, enabling both forward inference and backpropagation for gradient computation.</li>
<li><b>Topological Sorting</b>: The graph supports automatic topological sorting to ensure that nodes are executed in the correct order during the forward and backward passes.</li>
<li><b>Gradient and Data Management</b>: Methods for zeroing gradients, setting input data, and retrieving the output tensor values.</li>
<li><b>Randomization and Initialization</b>: The class provides functionality to initialize or randomize the parameters of nodes and their tensors.</li>
<li><b>Model Persistence</b>: Methods to save and load the graph to/from disk, allowing models to be persisted and restored for later use.</li>
<li><b>Optimizer Integration</b>: The class can interface with various optimizers (e.g., SGD, Adam) to update the weights of the nodes during training.</li>
</ul>
<p><b>Node Types</b>: The graph supports several types of nodes, including:</p><ul>
<li><b>Computation Nodes</b>: Operations like addition (<code>AddNode</code>), matrix multiplication (<code>MatMulNode</code>), and activation functions (e.g., <code>ReLUNode</code>, <code>SigmoidNode</code>, <code>SoftmaxNode</code>).</li>
<li><b>Loss Nodes</b>: Nodes such as <code>MeanSquaredErrorNode</code> and <code>BinaryCrossEntropyNode</code> that compute the loss function for model training.</li>
<li><b>Input/Output Nodes</b>: Nodes to manage input and output data tensors for the model.</li>
</ul>
<p><b>Error Handling</b>:</p><ul>
<li>If a node type is not found or an invalid configuration is provided for creating nodes, appropriate runtime exceptions are thrown.</li>
<li>Attempts to add incompatible nodes (e.g., scalar nodes) using the <code>addNode</code> function will trigger warnings or errors.</li>
</ul>
<p><b>Usage Example</b>: The typical workflow using <code>ComputeGraph</code> involves creating nodes, connecting them to form a graph, and performing forward and backward passes to train the model. The <code>update</code> function allows optimizers to be applied to update the parameters of the model during training.</p>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>This class is designed to be GPU-accelerated and is intended to be used in deep learning models where large-scale data and high computation power are required.</li>
<li>The class provides basic error handling for common issues like missing nodes or invalid node types.</li>
</ul>
</dd></dl>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge (<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2024/12/07 </dd></dl>

<p class="definition">Definition in file <a class="el" href="_compute_graph_8cuh_source.html">ComputeGraph.cuh</a>.</p>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0
</small></address>
</div><!-- doc-content -->
</body>
</html>
